package com.dreamwhale.machinery.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dreamwhale.machinery.config.DataResult;
import com.dreamwhale.machinery.config.UploadFile;
import com.dreamwhale.machinery.entity.YxStoreProductAttrResult;
import com.dreamwhale.machinery.dao.YxStoreProductAttrResultMapper;
import com.dreamwhale.machinery.service.YxStoreProductAttrResultService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>
 * 商品属性详情表 服务实现类
 * </p>
 *
 * @author Author
 * @since 2020-06-10
 */
@Service
public class YxStoreProductAttrResultServiceImpl extends ServiceImpl<YxStoreProductAttrResultMapper, YxStoreProductAttrResult> implements YxStoreProductAttrResultService {

    @Resource
    private YxStoreProductAttrResultMapper yxStoreProductAttrResultMapper;

    @Resource
    private UploadFile uploadFile;

    @Override
    public DataResult inquireGoodsSpecification(Integer productId) {


        YxStoreProductAttrResult yxStoreProductAttrResult = yxStoreProductAttrResultMapper.selectOne(new QueryWrapper<YxStoreProductAttrResult>().eq("product_id", productId));
        return new DataResult(yxStoreProductAttrResult);
    }


    @Override
    public DataResult releaseTaskPicture(MultipartFile file) {
        String fileName = uploadFile.writePicture(file, String.format("%s%s/", "certification/"));

        return DataResult.ok(fileName);
    }
}
